package com.hzlj.position.job.job;

import com.fz.common.redis.annotation.SyncLock;
import com.hzlj.position.config.service.JzJbxxDeviceBindService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class JzJbxxDeviceBindJob {
    @Resource
    private JzJbxxDeviceBindService jzJbxxDeviceBindService;

    /**
     * 每隔1个小时
     */
    @SyncLock(lockMs = 60000)
    @Scheduled(cron = "${job.device.delete:0 0/5 * * * ?}")
    public void updateNeverReport() {
        long start = System.currentTimeMillis();
        log.info("任务开始执行[定期清理需要删除的设备绑定数据]");
        int size = jzJbxxDeviceBindService.deleteJzJbxxDeviceBind();
        log.info("任务结束执行[定期清理需要删除的设备绑定数据],cost={},size={}", System.currentTimeMillis() - start, size);
    }
}
